<template>
  <div class="right_bottom">
    <div class="chart" ref="myChart"></div>
  </div>
</template>

<script>
import {getCompanyData} from "../api";

export default {
  name: 'LeftBottom',
  data () {
    return {
      data: ['企业注册数', '企业登陆数', '发布职位数', '发布岗位数', '企业在招数', '投递岗位数', '下载简历数', '邀约数'],
      newArray: []
    }
  },
  methods: {
    init () {
      const getChartDom = this.$refs.myChart
      const myChart = this.$echarts.init(getChartDom, 'dark')
      setInterval(() => {
        window.onresize = myChart.resize;
      }, 1000)
      myChart.setOption({
        // title: {
        //   text: '月度风险状况'
        // },
        tooltip: {},
        backgroundColor: 'rgb(14, 26, 45)',
        legend: {
          type: 'plain',
          right: '20px'
        },
        xAxis: {
          name: '月份',
          data: this.data
        },
        yAxis: {
          name: '风险数'
        },
        series: [{
          name: '2019年8月-9月',
          type: 'bar',
          data: this.newArray
        }]
      });
    },
    getCompany () {
      setInterval(() => {
        getCompanyData().then(res => {
          this.newArray = []
          const obj = res.data.data
          for (const i in obj) {
            this.newArray.push(obj[i])
          }
        })
        this.init()
      }, 3000)
    }
  },
  mounted () {
    this.init()
    this.getCompany()
  }
}
</script>

<style lang="scss" scoped>
@import "src/assets/scss/var_";

.right_bottom {

  .chart {
    width: $left_chart;
    height: $bottom_height;
    padding: 10px;
    box-sizing: border-box;
  }
}

</style>
